<?php

// 主页 
class IndexAction extends Action {
	public function index() {
		$think = new Model('Entry');
		//count total entries
		$this->count = $think->count();
		$this->content = $think->select();
		$this->display('index');
	}

	public function insert() {
		if (!$this->isPost()) {
			$this->error("该页面禁止访问");
		} else {
			$validate = array(
				array('name', 'require', '必须输入用户名', 1),
				array('content', 'require', '必须输入内容', 1)
			);
			$entry = new Model("Entry");
			if (!$entry->validate($validate)->create()) {
				$this->error = $entry->getError();
				$this->index();
			} else {
				$entry->add();
				$this->success("保存成功",'Index/index');
			}
		}
	}
	public function clear()
	{
		$entry = new Model();
		$entry->query("DELETE FROM think_entry");
		$this->success("删除成功"); 
	} 
	public function verify() {
		import('ORG.Util.Image');
		Image::buildImageVerify();
	}
}
